{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "7d7850d1",
   "metadata": {},
   "source": [
    "-------\n",
    "* 记录人：江丽婷\n",
    "* 时间：2021-11-15\n",
    "* week14\n",
    "* 主要参考文档：\n",
    "> 1.[Python官方文档] （https://docs.python.org/doc）\n",
    "> 2.[博客--函数]（https://www.cnblogs.com/xuzhichao/p/11570285.html）\n",
    "----\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "34e8b063",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-29T02:01:00.365467Z",
     "start_time": "2021-11-29T02:01:00.347865Z"
    }
   },
   "source": [
    "## 本周内容\n",
    "### 字典的一般方法\n",
    "\n",
    "> 1.函数的定义\n",
    "> 2.如何使用函数\n",
    "> 3.函数的返回值\n",
    "> 4.使用注释改进文档\n",
    "> 5.传递任意数量的实参\n",
    "> 6.函数与模块"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "554ccfb0",
   "metadata": {},
   "source": [
    "## 1.函数的定义\n",
    "\n",
    "* 定义函数：\n",
    "> 1.写def：def定义函数的第一步\n",
    "> 2.写定义函数的名称：def function_name\n",
    ">> 1.function_name 遵循变量名称定义的规则\n",
    "> 3.函数名称后加上\"():\"：def function_name(): ===>  f(x) = 2x    #注意空格和圆括号\n",
    "\n",
    "* 书写函数体\n",
    "> 1.函数的注释\n",
    "> 2.写函数的具体操作（函数体）\n",
    "> 3.注意：函数也是需要有tab键的间距\n",
    "\n",
    "\n",
    "* 使用函数(函数的调用)：\n",
    "> 1.function_name()\n",
    "\n",
    "* 函数存在的意义"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "00d89137",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:47:14.919275Z",
     "start_time": "2021-12-19T04:47:14.908584Z"
    }
   },
   "outputs": [],
   "source": [
    "def fib(n):     #write Fibonacci series up to n\n",
    "    \"\"\"Print a Fibonacci series up to n.\"\"\"\n",
    "    a,b = 0,1\n",
    "    while a < n:\n",
    "        print(a,end='')\n",
    "        a,b = b,a+b\n",
    "    print()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "f4d7ceb3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:47:19.785693Z",
     "start_time": "2021-12-19T04:47:19.769974Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "01123581321345589\n"
     ]
    }
   ],
   "source": [
    "fib(100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "418e03c8",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:47:21.680907Z",
     "start_time": "2021-12-19T04:47:21.664439Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function fib in module __main__:\n",
      "\n",
      "fib(n)\n",
      "    Print a Fibonacci series up to n.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(fib)     # 运行后第三行就是我们上面自己写的注释的内容"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "0d89437c",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:47:28.455822Z",
     "start_time": "2021-12-19T04:47:28.446835Z"
    }
   },
   "outputs": [],
   "source": [
    "## 尝试：写一个实现hello world的函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "685ebd16",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:47:28.783851Z",
     "start_time": "2021-12-19T04:47:28.768788Z"
    }
   },
   "outputs": [],
   "source": [
    "def hello():\n",
    "    \"\"\"打印hello world\"\"\"   #优秀的注释可以提高代码的可读性\n",
    "    print(\"hello world!\")\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "c3031c90",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:47:29.973026Z",
     "start_time": "2021-12-19T04:47:29.959641Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello world!\n"
     ]
    }
   ],
   "source": [
    "hello()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5b083ab4",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:47:36.869614Z",
     "start_time": "2021-12-19T04:47:36.855674Z"
    }
   },
   "source": [
    "## 如何使用函数（课本实践149）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "339294ea",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:47:37.529410Z",
     "start_time": "2021-12-19T04:47:37.512451Z"
    }
   },
   "outputs": [],
   "source": [
    "## 思考函数存在的意义？\n",
    "# 1. 可以通过调用函数的方式实现某个功能，使用人不需要考虑函数代码的内容\n",
    "# 2.节省时间，提升应用的效率\n",
    "# 3.函数一旦定义，就可按照一定的规则重复使用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "be8e1f00",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-29T03:17:11.772828Z",
     "start_time": "2021-11-29T03:17:11.759039Z"
    }
   },
   "outputs": [],
   "source": [
    "# 定义了一个名字叫 “search4vowels”的函数\n",
    "def search4vowels(word):\n",
    "    \"\"\"\n",
    "    打印文本中出现的元音字母\n",
    "    请输入你想要查询的文本内容\n",
    "    \"\"\"\n",
    "    vowels = set('aeiou')\n",
    "    word = input(\"Provide a word to search for vowels:\")\n",
    "    found = vowels.intersection(set(word)) # 交集运算\n",
    "    print(found)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "13d37321",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-29T03:17:11.964424Z",
     "start_time": "2021-11-29T03:17:11.951792Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function search4vowels in module __main__:\n",
      "\n",
      "search4vowels(word)\n",
      "    打印文本中出现的元音字母\n",
      "    请输入你想要查询的文本内容\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(search4vowels)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "664c40be",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-29T03:17:12.361992Z",
     "start_time": "2021-11-29T03:17:12.139592Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide a word to search for vowels:\n",
      "set()\n"
     ]
    }
   ],
   "source": [
    "search4vowels(\"bgfhje\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "e3852dc9",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-29T03:17:12.796633Z",
     "start_time": "2021-11-29T03:17:12.556812Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide a word to search for vowels:\n",
      "set()\n"
     ]
    }
   ],
   "source": [
    "search4vowels(\"fbnjdsadekw\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5f7519a4",
   "metadata": {},
   "source": [
    "* 下面的方法是不是太重复了，主要原因是没有对重复功能的代码块有特殊的定义（如：名称，注释等）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "804b8b19",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:48:43.705986Z",
     "start_time": "2021-12-19T04:48:34.465724Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide a word to search for vowels:hello yuzao\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'a', 'e', 'o', 'u'}"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vowels = set('aeiou')\n",
    "word = input(\"Provide a word to search for vowels:\")\n",
    "found = vowels.intersection(set(word))\n",
    "found"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "110f097d",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:48:59.065845Z",
     "start_time": "2021-12-19T04:48:49.395663Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide a word to search for vowels:hi goodbye\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'e', 'i', 'o'}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vowels = set('aeiou')\n",
    "word = input(\"Provide a word to search for vowels:\")\n",
    "found = vowels.intersection(set(word))\n",
    "found"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "42a663dd",
   "metadata": {},
   "source": [
    "## 3.函数的参数\n",
    "\n",
    "* <font style=\"color:red\">注意：函数的参数可以没有，如果有参数，则如下（分为形式参数和实际参数）：</font>\n",
    "\n",
    "> 1.形式参数（形参）\n",
    ">> 1.在定义过程中，函数的参数为形式参数\n",
    ">> 2.形式参数是虚拟的，不占用空间的\n",
    "\n",
    "> 2.实际参数（实参）\n",
    ">> 1.调用函数过程中，函数的参数为实际参数\n",
    ">> 2.调用函数时，形式参数被分配空间，成为实际参数并应用起来"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "aa7b5075",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-29T03:17:17.806098Z",
     "start_time": "2021-11-29T03:17:17.797248Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello world!\n"
     ]
    }
   ],
   "source": [
    "# 函数式可以没有参数的\n",
    "hello()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "9bbdc1d2",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-29T03:17:18.289608Z",
     "start_time": "2021-11-29T03:17:18.277019Z"
    }
   },
   "outputs": [],
   "source": [
    "# 定义函数\n",
    "def greet_user(username):\n",
    "    \"\"\"显示简单的问候语，输入你的名字\"\"\"\n",
    "    print(\"hello,\"+username.title()+\"!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "4000c9da",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-29T03:17:19.123712Z",
     "start_time": "2021-11-29T03:17:19.108688Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello,Jiang!\n"
     ]
    }
   ],
   "source": [
    "#调用函数： username = \"jiang\"\n",
    "greet_user(\"jiang\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "67fd9d65",
   "metadata": {},
   "source": [
    "* 当参数不止一个时：\n",
    "> 1. 位置参数\n",
    ">> 1.形式参数有多个值，如果实际参数直接赋值，要按照形式参数的先后顺序，这种方式称：位置参数赋值\n",
    ">> 2.在调用函数过程中，需要考虑如下：\n",
    ">>> 1.考虑位置\n",
    ">>> 2.考虑个数\n",
    "> 2.关键字参数\n",
    ">> 1.在调用函数时使用，我们直接在实参中 用赋值的方法去定义形参\n",
    ">> 2. 不需要考虑顺序，因为赋值已经确定了形式参数的值\n",
    "> 3.默认参数[https://docs.python.org/zh-cn/3/tutorial/controlflow.html#default-argument-values]\n",
    ">> 1.默认参数写在 形式参数中\n",
    ">> 2.默认参数存在的话，实际调用过程中可以忽略赋值的过程"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "92b5775f",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-29T03:29:11.361554Z",
     "start_time": "2021-11-29T03:29:11.350416Z"
    }
   },
   "outputs": [],
   "source": [
    "# 请注意，有两个参数\n",
    "def describe_pet(animal_type,pet_name):\n",
    "    \"\"\"显示宠物信息\"\"\"\n",
    "    print(\"\\nI have a \" + animal_type + \".\")\n",
    "    print(\"My \" + animal_type + \"'s name is \" +pet_name.title() + \".\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "106d4c56",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-29T03:29:12.100648Z",
     "start_time": "2021-11-29T03:29:12.083399Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "I have a dog.\n",
      "My dog's name is 豆豆.\n"
     ]
    }
   ],
   "source": [
    "describe_pet(\"dog\",\"豆豆\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "7a0a0ce6",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-29T03:29:17.255684Z",
     "start_time": "2021-11-29T03:29:17.139314Z"
    }
   },
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "describe_pet() missing 1 required positional argument: 'pet_name'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-5-31de85a1398a>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdescribe_pet\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"cat\"\u001b[0m\u001b[1;33m)\u001b[0m   \u001b[1;31m# 错误案例\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m: describe_pet() missing 1 required positional argument: 'pet_name'"
     ]
    }
   ],
   "source": [
    "describe_pet(\"cat\")   # 错误案例，只有一个参数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "e0c6f602",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-29T03:30:03.454768Z",
     "start_time": "2021-11-29T03:30:03.442208Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "I have a dog.\n",
      "My dog's name is 豆豆.\n"
     ]
    }
   ],
   "source": [
    "# 关键字参数\n",
    "describe_pet(animal_type=\"dog\",pet_name=\"豆豆\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "3757e88d",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-29T03:31:22.051506Z",
     "start_time": "2021-11-29T03:31:22.043820Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "I have a dog.\n",
      "My dog's name is 豆豆.\n"
     ]
    }
   ],
   "source": [
    "describe_pet(pet_name=\"豆豆\",animal_type=\"dog\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "041c0b5a",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-29T03:37:58.824707Z",
     "start_time": "2021-11-29T03:37:58.818078Z"
    }
   },
   "outputs": [],
   "source": [
    "# 默认参数(写在形式参数中的)\n",
    "# 请注意，有两个参数\n",
    "\n",
    "def describe_pet(pet_name,animal_type=\"dog\"):\n",
    "    \"\"\"显示宠物信息，animal_type 的默认值'dog'\"\"\"\n",
    "    print(\"\\nI have a \" + animal_type + \".\")\n",
    "    print(\"My \" + animal_type + \"'s name is \" +pet_name.title() + \".\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "040e1482",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-29T03:39:44.069539Z",
     "start_time": "2021-11-29T03:39:44.050219Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "I have a dog.\n",
      "My dog's name is 豆豆.\n"
     ]
    }
   ],
   "source": [
    "describe_pet(\"豆豆\",\"dog\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7345e1b9",
   "metadata": {},
   "source": [
    "--------------\n",
    "\n",
    "* 实操和注意（参数部分）\n",
    "> 1.如果想 关键字参数 和位置参数共同使用\n",
    ">> 1.位置参数需要放在关键字参数的前面\n",
    ">> 2.关键字参数放在末尾（均是关键字，不考虑顺序）\n",
    "> 2.默认参数\n",
    ">> 1.非默认参数需要放在默认参数前\n",
    ">>默认参数放在末尾"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "d2ef97bc",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:51:57.974363Z",
     "start_time": "2021-12-19T04:51:57.959819Z"
    }
   },
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-18-4c1a13f6ae51>, line 6)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-18-4c1a13f6ae51>\"\u001b[1;36m, line \u001b[1;32m6\u001b[0m\n\u001b[1;33m    func_test(x=1,2)     ?\u001b[0m\n\u001b[1;37m                         ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "#eg1 \n",
    "def func_test(x,y):\n",
    "    print(x)\n",
    "    print(y)\n",
    "    \n",
    "func_test(x=1,2)     ?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "fe8f18bf",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:51:46.977662Z",
     "start_time": "2021-12-19T04:51:46.967595Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "1\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "#eg2\n",
    "def func_test(x,y,z):\n",
    "    print(x)\n",
    "    print(y)\n",
    "    print(z)\n",
    "    \n",
    "func_test(2,1,z=3)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "7337f1b8",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:52:19.886759Z",
     "start_time": "2021-12-19T04:52:19.869913Z"
    }
   },
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "non-default argument follows default argument (<ipython-input-19-71c6316fbb41>, line 2)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-19-71c6316fbb41>\"\u001b[1;36m, line \u001b[1;32m2\u001b[0m\n\u001b[1;33m    def func_test(x,y=4,z):\u001b[0m\n\u001b[1;37m                  ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m non-default argument follows default argument\n"
     ]
    }
   ],
   "source": [
    "#eg3\n",
    "def func_test(x,y=4,z):\n",
    "    print(x)\n",
    "    print(y)\n",
    "    print(z)\n",
    "    \n",
    "func_test(2,1,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "a387eb34",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:52:36.272663Z",
     "start_time": "2021-12-19T04:52:36.263686Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "5\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "#eg3\n",
    "def func_test(x,z,y=3):\n",
    "    print(x)\n",
    "    print(y)\n",
    "    print(z)\n",
    "    \n",
    "func_test(2,3,5)    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "7ce0595c",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-29T03:51:04.357310Z",
     "start_time": "2021-11-29T03:51:04.347727Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "1\n"
     ]
    }
   ],
   "source": [
    "def func_text(x,y):\n",
    "    print(x)\n",
    "    print(y)\n",
    "    \n",
    "func_text(2,y=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "65befad0",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-29T03:51:46.452057Z",
     "start_time": "2021-11-29T03:51:46.447081Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "1\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "# eg2\n",
    "def func_text(x,y,z):\n",
    "    print(x)\n",
    "    print(y)\n",
    "    print(z)\n",
    "    \n",
    "func_text(2,1,z=3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "6a4b048d",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-29T03:54:11.535891Z",
     "start_time": "2021-11-29T03:54:11.522314Z"
    }
   },
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "non-default argument follows default argument (<ipython-input-18-86843f405ca0>, line 2)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-18-86843f405ca0>\"\u001b[1;36m, line \u001b[1;32m2\u001b[0m\n\u001b[1;33m    def func_text(x,y=1,z):\u001b[0m\n\u001b[1;37m                  ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m non-default argument follows default argument\n"
     ]
    }
   ],
   "source": [
    "# eg3\n",
    "def func_text(x,y=1,z):\n",
    "    print(x)\n",
    "    print(y)\n",
    "    print(z)\n",
    "    \n",
    "func_text(2,1,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "f26b0818",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:52:46.325541Z",
     "start_time": "2021-12-19T04:52:46.314021Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "1\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "# eg3\n",
    "def func_text(x,y,z):\n",
    "    print(x)\n",
    "    print(y)\n",
    "    print(z)\n",
    "    \n",
    "func_text(2,1,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8404ecfd",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
